package com.kingre.et.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 问卷
 * 
 * @author Jingui.Yu
 * 
 */
@Entity
@Table(name = "t_questionnaire")
public class Questionnaire extends BaseObject implements Serializable {
    private static final long serialVersionUID = -3949006853251505906L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false, length = 256)
    private String name;

    @Column(nullable = false, length = 512)
    private String high;

    @Column(nullable = false, length = 512)
    private String middle;

    @Column(nullable = false, length = 512)
    private String low;

    @Column(nullable = false, length = 512)
    private String suggest;

    @Column(name = "mean_score")
    private Float meanScore;

    @Column(name = "sd")
    private Float sd;

    @ManyToOne(targetEntity = Dimensionality.class)
    @JoinColumn(name = "dim_id")
    private Dimensionality dimension;

    @Transient
    private int value;

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Questionnaire)) {
            return false;
        }
        final Questionnaire questionnaire = (Questionnaire) o;
        return this.hashCode() == questionnaire.hashCode();
    }

    @Override
    public int hashCode() {
        int result;
        result = (id != null ? id.hashCode() : 0);
        result = 29 * result + (name != null ? name.hashCode() : 0) + (high != null ? high.hashCode() : 0)
                + (middle != null ? middle.hashCode() : 0) + (low != null ? low.hashCode() : 0)
                + (suggest != null ? suggest.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append("id", id).append("name", name).toString();
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getHigh() {
        return high;
    }

    public void setHigh(String high) {
        this.high = high;
    }

    public String getMiddle() {
        return middle;
    }

    public void setMiddle(String middle) {
        this.middle = middle;
    }

    public String getLow() {
        return low;
    }

    public void setLow(String low) {
        this.low = low;
    }

    public String getSuggest() {
        return suggest;
    }

    public void setSuggest(String suggest) {
        this.suggest = suggest;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public Float getMeanScore() {
        return meanScore;
    }

    public void setMeanScore(Float meanScore) {
        this.meanScore = meanScore;
    }

    public Float getSd() {
        return sd;
    }

    public void setSd(Float sd) {
        this.sd = sd;
    }

    public Dimensionality getDimension() {
        return dimension;
    }

    public void setDimension(Dimensionality dimension) {
        this.dimension = dimension;
    }

}
